package com.cdx.spring.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 切面： 额外功能+ 切入点
 * @author chedx
 * @data 2021/1/12 1:14 PM
 */
@Aspect
public class MyAspect {

    // 切入点复用
    @Pointcut("execution(* *(..))")
    public void myPointCut(){}


    // 额外功能 + 切入点 + 组装
    @Around(value = "myPointCut()")
    public Object arroud(ProceedingJoinPoint proceedingJoinPoint) {
        System.out.println("------aspect  log ");
        Object ret = null;
        try {
            ret = proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }

        return ret;
    }
}
